<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>订单待受理</title>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/font-awesome-ie7.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link href="css/jquery.datetimepicker.css" rel="stylesheet">
    <link rel="stylesheet" href="css/admin.css"/>

    <link rel="stylesheet" type="text/css" href="css/paging.css">

    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/jquery-placeholder/2.0.8/jquery.placeholder.min.js"></script>
    <![endif]-->
    <style>
        .stateMemo {
            white-space: pre-wrap !important;
            width: 170px !important;
            display: block;
            height: auto;

        }
    </style>
</head>
<body>
<div id="gray_bg"></div>
<!-- 删除订单开始 -->
<div id="deleteDiadog" class="diadog">
    <div class="diadog-tit">
        <div class="row">
            <div class="col-md-11 iewidth330"><span>确定操作？</span></div>
            <div class="col-md-1 ie8width100 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con" style="padding:30px 0">

        <div class="form-horizontal" role="form">
            <div class="row">

                <div class="col-md-12">
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label"><span
                                style="color: #e4393c">*</span>取消说明:</label>
                        <div class="col-sm-9">
                            <input id="remark" type="text" class="form-control">
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-3"></div>
                    <div class="col-md-2">
                        <button id="deleteSure" type="submit" class="btn btn-primary">确 定</button>
                    </div>
                    <div class="col-md-2">
                        <button id="deleteCancle" type="submit" class="btn btn-default">取 消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 删除订单结束 -->

<!-- header start -->
<div id="header" class="header">

</div>
<!-- header end -->
<!-- usercenter start -->
<div class="usercotent">
    <div id="center-left"></div>
    <div class="usercotentr floatr">
        <div class="user-tit" style="margin-bottom:10px">
            <h3>待受理</h3>
        </div>
        <div class="usercotent-con">
            <div class="btnList">
                <div class="col-md-2" style="width: 170px !important;">
                <strong class="ordertext">从：</strong><input id="datetimepicker_searchbegin" class="inputStory"
                type="text"
                style="width:110px !important;height: 34px !important;">
                </div>
                <div class="col-md-2" style="width: 170px !important;">
                <strong class="ordertext">到：</strong><input id="datetimepicker_searchend" class="inputStory" type="text"
                style="width:110px !important;height: 34px !important;">
                </div>
                <div class="col-md-2" style="width: 140px !important;">
                    <input id="search_keyvalue" class="inputStory" type="text"
                           style="width:140px !important;height: 34px !important;" placeholder="关键字">
                </div>
                <div class="col-md-2" style="width: 150px !important;">
                    <button style="width: 150px; height: 35px;float: left" id="order_search" type="button"
                            class="btn btn-success">搜索
                    </button>
                </div>
                <!--<div class="col-md-2" style="width: 170px !important;margin-left: 20px;">-->
                <!--<button style="width: 150px; height: 35px;float: left" id="export" type="button"-->
                <!--class="btn btn-primary">导 出-->
                <!--</button>-->
                <!--</div>-->
            </div>


            <div class="down">
                <table id="testMyGrid" class="table table-bordered table-hover"></table>
            </div>
            <!-- page start -->
            <nav class="totalpage floatr">
                <span>总共</span><strong id="totalpage"></strong><span>条</span>
                <div id="pageTool" style="margin-top:20px;"></div>
            </nav>
            <div class="clear"></div>
            <!-- page end -->
        </div>

    </div>
    <div class="clear"></div>
</div>

<!-- usercenter end -->

<!-- footer start -->
<div class="footer">
    <div class="bot">
        <p style="padding-top: 10px; text-align: center">Copyright (C) 都能印 2014-2016, all Rights Reserved |
            豫ICP备14024464号-1 | 增值电信业务经营许可证：豫B2-20150019</p>
        <p class="authentication" style="padding-bottom: 10px; padding-top: 10px;">
            <img src="img/footer1.png" alt="">
            <img src="img/footer2.png" alt="">
            <img src="img/footer3.png" alt="">
            <img src="img/footer4.png" alt="">
            <img src="img/footer5.png" alt="">
        </p>
    </div>
</div>
<!-- footer end -->
<script src="js/jquery.min-1-11-3.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/widget/admin.js"></script>
<script src="js/widget/myDataGrid.js"></script>
<script src="js/jquery.datetimepicker.full.js"></script>
<script type="text/javascript" src="js/query.js"></script>
<script type="text/javascript" src="js/paging.js"></script>
<script type="text/javascript">
    //开始
    $(function () {
        // body...
        $('#datetimepicker_searchbegin').datetimepicker({
            lang: 'ch',
            formatDate: 'Y-m-d',
            format: 'Y-m-d',
            timepicker: false,
            //minDate:'none', // yesterday is minimum date
            timepicker: false
        })
    })

    $(function () {
        // body...
        $('#datetimepicker_searchend').datetimepicker({
            lang: 'ch',
            formatDate: 'Y-m-d',
            format: 'Y-m-d',
            timepicker: false,
            //minDate:'none', // yesterday is minimum date
            timepicker: false
        })
    })
    var id;
    $(function () {
        initSideAccMenu("订单管理", "待受理");
        //表格数据
        $.ajax({
            url: "apis/user/ifpermission",
            type: 'post',
            dataType: 'json',
            data:{
                permissions:"user.order.pending.update"
            },
            async: false,
            contentType: 'application/json',
            success: function (res) {
                if (res.httpCode == 200) {
                    $("#testMyGrid").grid({
                        id: "testMyGrid",
                        pageTotalId: "totalpage",
                        pageToolId: "pageTool",
                        url: "apis/order/getpartnerorderpagelist?orderStatus=0",
                        method: "post",
                        columns: [
                            {field: 'idOrder', title: '#', conmethod: 'getRecordIndex', calcfield: '', kind: '', region: 0},
                            {field: 'createtime', title: '操作', conmethod: 'getPenging', calcfield: '', kind: '', region: 1},
//                {field: 'ordertype', title: '订单类型', conmethod: 'getOrdertype', calcfield: '', kind: '', region: 0},
                            {field: 'productName', title: '产品名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'orderCode', title: '订单编号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            //{field: 'productname', title: '业务类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'orderStatus', title: '订单状态', conmethod: 'getOrderStatus', calcfield: '', kind: '', region: 0},
                            {field: 'orderMoney', title: '订单金额', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'productItemName', title: '订单描述', conmethod: 'getOrderDes', calcfield: '', kind: '', region: 1},
                            {field: 'customerName', title: '联系人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'customerWxNickName', title: '微信名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'customerPhone', title: '联系电话', conmethod: 'getStrPhone', calcfield: '', kind: '', region: 1},
                            {field: 'createTime', title: '下单时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                            {field: 'remark', title: '订单备注', conmethod: 'getRemark', calcfield: '', kind: '', region: 1}
                        ],
                        pagesize: 10
                    });
                } else {
                    $("#testMyGrid").grid({
                        id: "testMyGrid",
                        pageTotalId: "totalpage",
                        pageToolId: "pageTool",
                        url: "apis/order/getpartnerorderpagelist?orderStatus=0",
                        method: "post",
                        columns: [
                            {field: 'idOrder', title: '#', conmethod: 'getRecordIndex', calcfield: '', kind: '', region: 0},
//                            {field: 'createtime', title: '操作', conmethod: 'getPenging', calcfield: '', kind: '', region: 1},
//                {field: 'ordertype', title: '订单类型', conmethod: 'getOrdertype', calcfield: '', kind: '', region: 0},
                            {field: 'partnerName', title: '合伙人企业名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'productName', title: '产品名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'orderCode', title: '订单编号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            //{field: 'productname', title: '业务类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'orderStatus', title: '订单状态', conmethod: 'getOrderStatus', calcfield: '', kind: '', region: 0},
                            {field: 'orderMoney', title: '订单金额', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'productItemName', title: '订单描述', conmethod: 'getOrderDes', calcfield: '', kind: '', region: 1},
                            {field: 'customerName', title: '联系人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'customerWxNickName', title: '微信名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                            {field: 'customerPhone', title: '联系电话', conmethod: 'getStrPhone', calcfield: '', kind: '', region: 1},
                            {field: 'createTime', title: '下单时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                            {field: 'remark', title: '订单备注', conmethod: 'getRemark', calcfield: '', kind: '', region: 1}

                        ],
                        pagesize: 10
                    });
                }
            }
        });

//        $("#testMyGrid").grid({
//            id: "testMyGrid",
//            pageTotalId: "totalpage",
//            pageToolId: "pageTool",
//            url: "apis/order/getpartnerorderpagelist?orderStatus=0",
//            method: "post",
//            columns: [
//                {field: 'idOrder', title: '#', conmethod: 'getRecordIndex', calcfield: '', kind: '', region: 0},
//                {field: 'createtime', title: '操作', conmethod: 'getPenging', calcfield: '', kind: '', region: 1},
////                {field: 'ordertype', title: '订单类型', conmethod: 'getOrdertype', calcfield: '', kind: '', region: 0},
//                {field: 'productName', title: '产品名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'orderCode', title: '订单编号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                //{field: 'productname', title: '业务类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'orderStatus', title: '订单状态', conmethod: 'getOrderStatus', calcfield: '', kind: '', region: 0},
//                {field: 'orderMoney', title: '订单金额', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'productItemName', title: '订单描述', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'customerName', title: '联系人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'customerWxNickName', title: '微信名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
//                {field: 'customerPhone', title: '联系电话', conmethod: 'getStrPhone', calcfield: '', kind: '', region: 1},
//                {field: 'createTime', title: '下单时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
//                {field: 'remark', title: '订单备注', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0}
//
//            ],
//            pagesize: 10
//        });

    })
    //结束
    //注释手机号码
    function getStrPhone() {
        var ts = arguments[0] || "";
        var order = arguments[1];
        var shtml = "";
//        if (order.orderStatus <= 0) {
//            var mphone = order.customerPhone.substr(0, 3) + '****' + order.customerPhone.substr(7);
//        } else {
//            var mphone = order.customerPhone;
//        }
        if (order.customerPhone) {
            var mphone = order.customerPhone.substr(0, 3) + '****' + order.customerPhone.substr(7);
        } else {
            var mphone = ""
        }
        shtml += "<span>" + mphone + "</span>";
        return shtml;
    }
    ;
    //    订单描述
    function getOrderDes() {
        var order = arguments[1];
        var shtml = "";
        if(order.productItemName == null || order.productItemName == ""){
            shtml = ""
        }else if(order.productItemName.length > 10){
            shtml = "<span class='stateMemo'>"+order.productItemName+"</span>"
        }
        return shtml;
    }
    ////受理订单
    function getPenging() {
        var ts = arguments[0] || "";
        var order = arguments[1];
        var shtml = "";
        shtml += "<a onclick=\"toPenging(" + order.id + ")\">受理</a>";
        shtml += "&nbsp;&nbsp;";
        shtml += "<a onclick=\"toCancel(" + order.id + ")\">取消订单</a>";


        return shtml;
    }
    ;
    //    订单备注
    function getRemark() {
        var order = arguments[1];
        var shtml = "";
        if(order.remark == null || order.remark == ""){
            shtml = ""
        }else{
            shtml = "<span class='stateMemo'>"+order.remark+"</span>"
        }
        return shtml;
    }
    //取消订单
    function toCancel(id) {
        $("#gray_bg").css({"height": $(document).height()});
        $("#deleteDiadog").show();
        $("#gray_bg").show();
        $("#deleteDiadog").center();
        $("#remark").val("");
        $("#deleteSure").click(function () {
            var remark = $("#remark").val();
            if (remark == null || remark == "") {
                alert("说明不能为空");
                return;
            }
            var url = "apis/order/voidpartnerorder";
            var datajson = {"id": id, "voidMemo": remark};
//            console.log(datajson);
            $.ajax({
                url: url,
                type: 'post',
                data: {
                    PartnerOrder: JSON.stringify(datajson)
                },
                dataType: 'json',
                async: false,
                contentType: 'application/json',
                success: function (res) {
//                    console.log(res);
                    if (res.httpCode == 200) {
                        alert("订单取消成功");
                        window.location.reload();
//
                    } else {
                        alert(res.msg);
                    }
                }
            });

        })

    }

    //受理订单弹出
    function toPenging(g) {

        var url = "apis/order/acceptpartnerorder";
        var datajson = {
            "id": g
        };
        $.ajax({
            url: url,
            type: 'post',
            data: {
                PartnerOrder: JSON.stringify(datajson)
            },
            dataType: 'json',
            async: false,
            contentType: 'application/json',
            success: function (res) {
//                console.log(res);
                if (res.httpCode == 200) {
                    alert("受理成功");
                    window.location.reload();
//
                } else {
                    alert(res.msg);
                }
            }
        });


    }
    //center
    jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", ( $(window).height() - this.height() ) / 2 + $(window).scrollTop() + "px");
        this.css("left", ( $(window).width() - this.width() ) / 2 + $(window).scrollLeft() + "px");
        return this;
    }
    //获取时间
    function getTime() {
        var ts = arguments[0] || 0;
        var t, y, m, d, h, i, s;
        t = ts ? new Date(ts) : new Date();
        y = t.getFullYear();
        m = t.getMonth() + 1;
        d = t.getDate();
        h = t.getHours();
        i = t.getMinutes();
        s = t.getSeconds();
        // 可根据需要在这里定义时间格式
        return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s);
    }
    $("#order_search").click(function () {
        var data = getSearchData();
        if ($("#search_keyvalue").val() == null) {
            alert("请输入关键字进行查询");
            return;
        }
        $("#testMyGrid").grid("search", data);
    })
    function getSearchData() {
        var begintime = $.trim($("#datetimepicker_searchbegin").val());
        var endtime = $.trim($("#datetimepicker_searchend").val());
        var keyword = $.trim($("#search_keyvalue").val());
        if ((begintime == "") && (endtime == "") && (keyword == "")) {
            var data = null;
        } else {
            if ((begintime != "") && (endtime != "") && (keyword != "")) {
                var data = {
                    "beginDate": begintime + " 00:00:00",
                    "endDate": endtime + " 23:59:59",
                    "keyWord": keyword
                }
            } else if ((begintime == "") && (endtime == "") && (keyword != "")) {
                var data = {
                    "keyWord": keyword
                }
            } else if ((begintime == "") && (endtime != "") && (keyword != "")) {
                var data = {
                    "keyWord": keyword
                }
            } else if ((begintime != "") && (endtime == "") && (keyword != "")) {
                var data = {
                    "keyWord": keyword
                }
            } else if ((begintime != "") && (endtime != "") && (keyword == "")) {
                var data = {
                    "beginDate": begintime + " 00:00:00",
                    "endDate": endtime + " 23:59:59"
                }
            } else {
                var data = null;
            }
        }
        return data;
    }
    //关闭
    $(".close,#deleteCancle").click(function () {
        $("#gray_bg").hide();
        $("#franchiseDiadog").hide();
        $("#deleteDiadog").hide();
    });
</script>
</body>
</html>